#if !defined(PERCEPTION_VISUALIZER_H_)
#define PERCEPTION_VISUALIZER_H_

#include <pcl/point_cloud.h>
#include <pcl/visualization/pcl_visualizer.h>

namespace autodrive {
namespace perception {

template <typename PointT>
void pcl_show(pcl::visualization::PCLVisualizer::Ptr const& viewer,
              typename pcl::PointCloud<PointT>::Ptr pcl_in, double pt_size,
              double r, double g, double b, std::string const& cloud_id,
              int viewport_id) noexcept(false) {
  if (viewer->contains(cloud_id)) {
    throw std::runtime_error("cloud name: " + cloud_id +
                             " is used before,please check");
  }

  if (!pcl_in->empty()) {
    viewer->addPointCloud<PointT>(pcl_in, cloud_id, viewport_id);
    viewer->setPointCloudRenderingProperties(
        pcl::visualization::PCL_VISUALIZER_POINT_SIZE, pt_size, cloud_id,
        viewport_id);
    viewer->setPointCloudRenderingProperties(
        pcl::visualization::PCL_VISUALIZER_COLOR, r, g, b, cloud_id,
        viewport_id);
  }
}

}  // namespace perception
}  // namespace autodrive

#endif  // PERCEPTION_VISUALIZER_H_
